﻿@using WebShop.Infrastructure

@model WebShop.ViewModels.ProductsInCart

<table>
    <tr>
        <th>
            ProductName
        </th>
        <th>
            Category
        </th>
        <th>
            QuantityPerUnit
        </th>
        <th>
            UnitPrice
        </th>
        <th>
            UnitsInStock
        </th>
        <th>
            Discontinued
        </th>
        <th>
            Quantity
        </th>
        <th></th>
    </tr>

@for (int i = 0; i < Model.Products.Count; i++)
{
    <tr>
        @Html.HiddenFor(modelItem => modelItem.Products[i].ProductID)
        <td>
            @Html.ActionLink(Model.Products[i].Product.ProductName, "Details", "Products", new { id = Model.Products[i].ProductID }, new { title = "View products details for: " + Model.Products[i].Product.ProductName })
        </td>
        <td>
            @Html.DisplayFor(modelItem => modelItem.Products[i].Product.Category.CategoryName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => modelItem.Products[i].Product.QuantityPerUnit)
        </td>
        <td>
            <span class="UnitPrice">
                @Html.DisplayFor(modelItem => modelItem.Products[i].Product.UnitPrice)
            </span>
        </td>
        <td>
            @Html.DisplayFor(modelItem => modelItem.Products[i].Product.UnitsInStock)
        </td>
        <td>
            @Html.DisplayFor(modelItem => modelItem.Products[i].Product.Discontinued)
        </td>
        <td>
            @if (Model.EditableCart)
            {
                @Html.EditorFor(modelItem => modelItem.Products[i].Quantity)
            }
            else
            {
                @Html.DisplayFor(modelItem => modelItem.Products[i].Quantity)
            }
        </td>
        <td>
            @if (Model.EditableCart)
            {
                @Html.ActionLink("Delete", "Delete", new { id = Model.Products[i].ProductID })
            }
        </td>
    </tr>
}

</table>
    
<p>
    <label class="TotlUnitPrice"></label>
</p>